#include "SettingDialog.h"

SettingDialog::SettingDialog(ShowMode ShowMode, Language language)
{
    m_ShowMode = ShowMode;
    m_NowLanguage = language;

    // 初始化控件
    m_LanguageBtn = new QPushButton("中文");
    m_ShowModeBtn = new QPushButton("白天");
    m_Layout      = new QHBoxLayout(this);
    m_Layout->addWidget(m_LanguageBtn);
    m_Layout->addWidget(m_ShowModeBtn);

    connect(m_LanguageBtn, &QPushButton::clicked, this, [=](){
       if(m_LanguageBtn->text() == "中文")
       {
           m_LanguageBtn->setText("英文");
           senderLanguage(Language::English);
           XMLFunc::xmlValueModify(XMLFunc::ConfigXmlPath, XMLLanguageKey, "English");
       }else{
           m_LanguageBtn->setText("中文");
           senderLanguage(Language::Chinese);
           XMLFunc::xmlValueModify(XMLFunc::ConfigXmlPath, XMLLanguageKey, "Chinese");
       }
    });

    connect(m_ShowModeBtn, &QPushButton::clicked, this, [=](){
        if(m_ShowModeBtn->text() == "白天")
        {
            m_ShowModeBtn->setText("黑夜");
            senderShowMode(ShowMode::NIGHT);
            XMLFunc::xmlValueModify(XMLFunc::ConfigXmlPath, XMLShowModeKey, "Night");
        }else{
            m_ShowModeBtn->setText("白天");
            senderShowMode(ShowMode::DAY);
            XMLFunc::xmlValueModify(XMLFunc::ConfigXmlPath, XMLShowModeKey, "Day");
        }
    });
    this->resize(100, 100);
}
